<script setup lang="ts">
  import { Field } from 'vee-validate';
  import { DynamicRadioOption } from '@/components/types';
  import { useLocale } from '@/locales/useLocale';
  const { t } = useLocale();

  const props = withDefaults(
    defineProps<{
      name: string;
      label?: string;
      options: DynamicRadioOption[];
      size?: 'large' | 'small' | 'default';
      animateClass?: string;
    }>(),
    {
      name: 'default',
      label: '',
      //@ts-ignore
      options: [] as DynamicRadioOption[],
      size: 'default',
      animateClass: '',
    }
  );
</script>

<template>
  <Field :name="name" v-slot="{ value, field, errorMessage }">
    <el-form-item
      :error="errorMessage"
      :label="label && t(label)"
      :size="size"
      :class="animateClass"
    >
      <el-radio-group :model-value="value" v-bind="{ ...field, ...$attrs }">
        <el-radio v-for="option in options" :label="option.value" :key="option.value">
          {{ option.label }}
        </el-radio>
      </el-radio-group>
    </el-form-item>
  </Field>
</template>

<style lang="scss"></style>
